﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="PhongBan.aspx.cs" Inherits="PhongBan" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <p>Thêm phòng ban:</p>
    <p>
        <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="objDepartments" 
            Height="50px" Width="300px" AutoGenerateRows="False" 
            DataKeyNames="DepartmentID"
            DefaultMode="Insert"
            >
            <Fields>
                <asp:TemplateField HeaderText="Name: ">
                    <InsertItemTemplate>
                        <asp:TextBox ID="txtName" Text='<%# Bind("Name") %>' runat="server" SortExpression="Name"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="URL Photo: ">
                    <InsertItemTemplate>
                        <asp:TextBox ID="txtURLPhoto" Text='<%# Bind("URLPhoto") %>' runat="server" SortExpression="URLPhoto"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="URL Home Page: ">
                    <InsertItemTemplate>
                        <asp:TextBox ID="txtURLHomePage" Text='<%# Bind("URLHomePage") %>' runat="server" SortExpression="URLHomePage"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Show Control: ">
                    <InsertItemTemplate>
                        <asp:TextBox ID="txtShowControl" Text='<%# Bind("ShowControl") %>' runat="server" SortExpression="ShowControl"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:CommandField CancelText="Hủy" InsertText="Thêm" NewText="Thêm phòng" ShowInsertButton="true" />
            </Fields>
        </asp:DetailsView>
    </p>

    <asp:GridView ID="grvDepartment" runat="server" BackColor="White" 
        BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" 
        GridLines="Horizontal" AllowPaging="True" AllowSorting="True" 
    AutoGenerateColumns="False" DataKeyNames="DepartmentID" 
    DataSourceID="objDepartments">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="DepartmentID" HeaderText="DepartmentID" 
                InsertVisible="False" ReadOnly="True" SortExpression="DepartmentID" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:TemplateField HeaderText="URLPhoto" SortExpression="URLPhoto">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("URLPhoto") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLPhoto") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="URLHomePage" SortExpression="URLHomePage">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("URLHomePage") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" 
                        NavigateUrl='<%# Eval("URLHomePage") %>' Text='<%# Eval("Name") %>'></asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ShowControl" HeaderText="ShowControl" 
                SortExpression="ShowControl" />
        </Columns>
        <FooterStyle BackColor="White" ForeColor="#333333" />
        <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="White" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F7F7F7" />
        <SortedAscendingHeaderStyle BackColor="#487575" />
        <SortedDescendingCellStyle BackColor="#E5E5E5" />
        <SortedDescendingHeaderStyle BackColor="#275353" />
    </asp:GridView>    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PagingDataConnectionString %>" 
        SelectCommand="SELECT * FROM [Departments]"></asp:SqlDataSource>
<asp:ObjectDataSource ID="objDepartments" runat="server" DeleteMethod="Delete" 
    InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" 
    SelectMethod="GetData" 
    TypeName="PagingDataTableAdapters.DepartmentsTableAdapter" 
    UpdateMethod="Update">
    <DeleteParameters>
        <asp:Parameter Name="Original_DepartmentID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="URLPhoto" Type="String" />
        <asp:Parameter Name="URLHomePage" Type="String" />
        <asp:Parameter Name="ShowControl" Type="String" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="URLPhoto" Type="String" />
        <asp:Parameter Name="URLHomePage" Type="String" />
        <asp:Parameter Name="ShowControl" Type="String" />
        <asp:Parameter Name="Original_DepartmentID" Type="Int32" />
    </UpdateParameters>
</asp:ObjectDataSource>
</asp:Content>

